package com.zxy.controlcenter.core.log.factory;

import com.zxy.controlcenter.core.utils.DateUtils;
import com.zxy.controlcenter.modular.system.model.LoginLog;
import com.zxy.controlcenter.modular.system.model.OperationLog;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component;

/**
 * 日志对象创建工厂
 *
 * @author fengshuonan
 * @date 2016年12月6日 下午9:18:27
 */
public class LogFactory {


    /**
     * 创建操作日志
     */
    public static OperationLog createOperationLog(Long logType, Long userId, String bussinessName, String clazzName, String methodName, String msg, String statusCode) {
        OperationLog operationLog = new OperationLog();
        operationLog.setLogType(logType);
        operationLog.setLogName(bussinessName);
        operationLog.setUserId(userId);
        operationLog.setClassName(clazzName);
        operationLog.setMethod(methodName);
        operationLog.setCreateTime(DateUtils.getNowTimeStamp());
        operationLog.setStatusCode(statusCode);
        operationLog.setMessage(msg);
        return operationLog;
    }

    /**
     * 创建登录日志
     */
    public static LoginLog createLoginLog(String logName, Long userId, String msg, String ip, String statusCode) {
        LoginLog loginLog = new LoginLog();
        loginLog.setLogName(logName);
        loginLog.setUserId(userId);
        loginLog.setCreateTime(DateUtils.getNowTimeStamp());
        loginLog.setStatusCode(statusCode);
        loginLog.setIpAddress(ip);
        loginLog.setMessage(msg);
        return loginLog;
    }
}
